var express = require('express');
var bodyParser = require('body-parser');
var sign = require('./sign.js');

exports.list = function(req,res){

    var data=sign.delEmptyValue(req.body);
    sign.dataReq(req,data,req.session.apikey,'/sysmanage/announcement/list',"POST",function(ResData){
        if(ResData!=""){
            res.json(ResData);
        }
    });
}
exports.allUser = function(req,res){
	
	sign.nullDataReq(req,req.session.apikey,'/sysmanage/announcement/allUser','post',function(ResData){
		if(ResData!=''){
			res.send(ResData);
		}
	})
}
exports.edit= function(req,res){

	var data=req.body
	if(!data.sendUsers){
		data["sendUsers"]=['0'];
		// data.append(sendUsers:['0']);
	}else if(!(data.sendUsers instanceof Array)){
		var idArray=[];
		idArray.push(data.sendUsers)
		data["sendUsers"]=idArray;
	}
	sign.dataReq(req,data,req.session.apikey,'/sysmanage/announcement/edit',"POST",function(ResData){
        if(ResData!=""){
            res.json(ResData);
        }
    });
	

}
exports.mylist = function(req,res){
	
	sign.nullDataReq(req,req.session.apikey,'/sysmanage/announcement/mylist','post',function(ResData){
		if(ResData!=''){
			res.send(ResData);
		}
	})
}
exports.myAllList = function(req,res){
	sign.dataReq(req,req.body,req.session.apikey,'/sysmanage/announcement/myAllList','post',function(ResData){
		if(ResData!=''){
			res.send(ResData);
		}
	})
}


exports.read = function(req,res){
    sign.dataReq(req,req.body,req.session.apikey,'/sysmanage/announcement/read',"POST",function(ResData){
        if(ResData!=""){
            res.json(ResData);
        }
    });
}
exports.del= function(req,res){
	var data=req.body;
	var val= req.body['ids[]'];
	sign.dataReq(req,{'ids':[val]},req.session.apikey,'/sysmanage/announcement/del','post',function(ResData){
		if(ResData!=''){
			res.send(ResData);
		}
	})

}

